 

        var ROOT_PATH="__ROOT__",ADMIN_PATH="{$_SERVER['SCRIPT_NAME']}", FFCMS_VERSION='v16';
    
  

		<a class="layui-btn layui-btn-xs" lay-event="dmedit">编辑</a>
		<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
	
  

            <div class="layui-btn-group">
		<a class="layui-btn layui-btn-sm" lay-event="edit"><i class="layui-icon  layui-icon-edit"></i></a>
		<a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del"><i class="layui-icon  layui-icon-delete"></i></a>
            </div>    
                <div class="layui-input-inline">
		<input class="layui-input" id="textdemo" placeholder="请输入视频ID或弹幕关键字">
		</div>
               <button  class="layui-btn" type="button"  lay-submit="search_submits" type="button" lay-filter="reloadlst_submit" >搜索</button>
	
        
  

		<a class="layui-btn layui-btn-xs" lay-event="edit">误报</a>
		<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
	
  

   
    <a class="layui-btn layui-btn-danger layui-btn-sm" lay-event="del" title="删除"><i class="layui-icon  layui-icon-delete"></i></a>
 

  

		<div class="layui-card-body" style="padding: 15px;">
        <form class="layui-form" lay-filter="component-form-group" id="submits" onsubmit="return false">
            <div class="layui-row layui-col-space10 layui-form-item">
                <input type="hidden" name="cid" value="{{ d.cid }}">
                <div class="layui-col-lg5">
                    <label class="layui-form-label">弹幕ID：</label>
                    <div class="layui-input-block">
                        <input type="text" name="id" placeholder="请输入名称" autocomplete="off"
                               lay-verify="required" class="layui-input"
                               value="{{ d.id?d.id:'' }}" {{# if(d.id){ }}disabled{{# } }}>
                    </div>
                </div>
                <div class="layui-col-lg5">
                    <label class="layui-form-label">颜色：</label>
  						<div class="layui-input-block">
							<div class="layui-input-inline" style="width: 120px;">
								<input type="text" name="color" placeholder="请选择颜色" class="layui-input" id="test-form-input" value="{{ d.color?d.color:'' }}">
							</div>
						<div class="layui-inline" style="left: -11px;">
						<div id="test-form"></div>
					</div>
				</div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">弹幕内容</label>
                    <div class="layui-input-block">
                    <textarea name="text" placeholder="请输入内容" class="layui-textarea" lay-verify="required">{{ d.text ? d.text:''}}</textarea>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit="" lay-filter="bond_sumbit">提交</button>
                </div>
            </div>
			
        </form>
    </div>

  

install_dir = "{$GLOBALS['config']['site']['install_dir']}";
layui.use(['form', 'laydate', 'laypage', 'table', 'layer', 'element', 'colorpicker'], function() {
	var laydate = layui.laydate,
		laypage = layui.laypage,
		layer = layui.layer,
		table = layui.table,
		element = layui.element,
		form = layui.form,
		laytpl = layui.laytpl,
		colorpicker = layui.colorpicker;
	var api = install_dir + 'static/player/cj/dplayer/';
	element.on('tab(dmku)', function(data) {
		if (data.index == 2) {
			dmlist()
		} else if (data.index == 3) {
			report()
		}
	});

	function dmlist() {
		table.render({
			elem: '#dmlist',
			url: api + '?ac=list',
			title: '用户表',
			page: true,
			toolbar: '#listTool',
			cols: [
				[{
					type: 'checkbox',
					fixed: 'left'
				}, {
					field: 'cid',
					title: 'ID',
					value: [4],
					width: 60,
					align: 'center',
					fixed: 'left',
					totalRowText: '合计：'
				}, {
					field: 'id',
					title: '视频ID',
					width: 200
				}, {
					field: 'user',
					title: '发布者',
					width: 100
				}, {
					field: 'text',
					title: '弹幕内容',
					width: 300
				}, {
					field: 'type',
					title: '类型',
					width: 80
				}, {
					field: 'color',
					title: '弹幕颜色',
					width: 180
				}, {
					field: 'videotime',
					title: '时间点',
					width: 120
				}, {
					field: 'ip',
					title: '发送IP',
					width: 90
				}, {
					field: 'time',
					title: '发送时间',
					width: 110
				}, {
					field: 'size',
					title: '弹幕大小',
					width: 90
				}, {
					fixed: 'right',
					title: '操作',
					width: 120,
					align: 'center',
					toolbar: '#listbar'
				}]
			]
		})
	}
	function report() {
		table.render({
			elem: '#report',
			url: api + '?ac=reportlist',
			title: '用户表',
			page: true,
			toolbar: '#reportTool',
			cols: [
				[{
					type: 'checkbox',
					fixed: 'left'
				}, {
					field: "cid",
					title: 'ID',
					value: [4],
					width: 60,
					align: 'center',
					fixed: 'left',
					fixed: 'left',
					totalRowText: '合计：'
				}, {
					field: "id",
					title: '视频ID',
					width: 100
				}, {
					field: "text",
					title: '弹幕内容',
					width: 300
				}, {
					field: "type",
					title: '举报类型',
					width: 100
				}, {
					field: "ip",
					title: '发送IP',
					width: 100
				}, {
					field: "time",
					title: '发送时间',
					width: 110
				}, {
					fixed: 'right',
					title: '操作',
					width: 120,
					align: 'center',
					toolbar: '#reportbar'
				}]
			]
		})
	}
	table.on('toolbar(dmlist)', function(obj) {
		var checkStatus = table.checkStatus(obj.config.id),
			data = checkStatus.data;
		if (data.length === 0) {
			layer.msg('请选择一行');
			return
		}
		switch (obj.event) {
		case 'add':
			layer.msg('添加');
			break;
		case 'edit':
			if (data.length === 0) {
				layer.msg('请选择一行')
			} else if (data.length > 1) {
				layer.msg('只能同时编辑一个')
			} else {
				editdm(data[0])
			}
			break;
		case 'del':
			if (data.length === 0) {
				layer.msg('请选择一行')
			} else {
				var dmid = new Array();
				data.forEach(function(tm) {
					dmid.push(tm.cid)
				});
				layer.confirm('真的删除选择行么', function(index) {
					delid(dmid.join());
					table.reload('dmlist', {
						url: api + '?ac=list'
					});
					table.reload('report', {
						url: api + '?ac=reportlist'
					});
					layer.close(index)
				})
			}
			break
		}
	});
	table.on('toolbar(report)', function(obj) {
		var checkStatus = table.checkStatus(obj.config.id),
			data = checkStatus.data,
			layEvent = obj.event;
		if (data.length === 0) {
			layer.msg('请选择一行');
			return
		}
		var dmid = new Array();
		data.forEach(function(tm) {
			dmid.push(tm.cid)
		});
		if (layEvent === 'del') {
			layer.confirm('真的删除所选举报列表么', function(index) {
				delid(dmid.join());
				table.reload('dmlist', {
					url: api + '?ac=list'
				});
				layer.close(index)
			})
		} else if (layEvent === 'edit') {
			layer.confirm('真的移除所选举报列表么', function(index) {
				delreport(dmid.join());
				table.reload('report', {
					url: api + '?ac=reportlist'
				});
				layer.close(index)
			})
		}
	});
	table.on('tool(dmlist)', function(obj) {
		var data = obj.data,
			layEvent = obj.event;
		if (layEvent === 'detail') {
			layer.msg('查看操作')
		} else if (layEvent === 'del') {
			layer.confirm('真的删除行么', function(index) {
				obj.del();
				var dmid = data.cid;
				delid(dmid);
				layer.close(index)
			})
		} else if (layEvent === 'dmedit') {
			editdm(data)
		}
	});
	table.on('tool(report)', function(obj) {
		var data = obj.data,
			layEvent = obj.event;
		if (layEvent === 'detail') {
			layer.msg('查看操作')
		} else if (layEvent === 'del') {
			layer.confirm('真的删除行么', function(index) {
				obj.del();
				var dmid = data.cid;
				delid(dmid);
				layer.close(index)
			})
		} else if (layEvent === 'edit') {
			layer.confirm('移除举报么', function(index) {
				obj.del();
				var dmid = data.cid;
				delreport(dmid);
				layer.close(index)
			})
		}
	});
	form.on('submit(reloadlst_submit)', function(data) {
		var key = $('#textdemo').val().trim();
		if (key === '') {
			table.reload('dmlist', {
				url: api + '?ac=list'
			})
		} else {
			table.reload('dmlist', {
				url: api + '?ac=so&key=' + key
			})
		}
	});
	form.on('submit(bond_sumbit)', function(data) {
		layer.msg('正在提交', {
			time: 5000000
		});
		$.ajax({
			type: 'POST',
			data: data.field,
			url: api + '?ac=edit',
			success: function(data) {
				layer.msg('保存完成', {
					time: 1000
					,shade:0.6
				})
			}
		})
	});

	function editdm(data) {
		var content = $("#bondTemplateList").html();
		laytpl(content).render(data, function(string) {
			layer.open({
				type: 1,
				title: "修改弹幕",
				area: ['800px', '350px'],
				content: string
			});
			colorpicker.render({
				elem: '#test-form',
				color: 'rgb(68,66,66)',
				format: 'rgb',
				done: function(color) {
					$('#test-form-input').val(color)
				}
			})
		})
	}
	function delreport(id) {
		$.ajax({
			url: api + "?ac=del&type=report&id=" + id,
			success: function(data) {
				layer.msg('移除成功', {
					time: 1000
				})
			}
		})
	}
	function delid(id) {
		$.ajax({
			url: api + "?ac=del&type=list&id=" + id,
			success: function(data) {
				layer.msg('删除完成', {
					time: 1000
				})
			}
		})
	}
	colorpicker.render({
		elem: '#color11',
		color: $("#color1").val(), 
		predefine: true,
		colors: ['#c93bf4', '#ff8c00', '#00ced1', '#9d8a0e', '#ff6429'],
		done: function(color) {
			$('#color1').val(color)
		}
	});
	form.on('switch(danmuStatus)', function(data) {
		layer.msg('弹幕功能：' + (this.checked ? '开启' : '关闭'));
		if (this.checked) {
			$('#danmu').show()
		} else {
			$('#danmu').hide()
		}
	});
	form.on('radio(adsType)', function(data) {
		if (data.value == 1) {
			$("#adsvod").show();
			$("#adspic").hide()
		} else {
			$("#adspic").show();
			$("#adsvod").hide()
		}
	});
	form.on('submit(save)', function(data) {
		layer.msg('正在提交', {
			time: 30000,
			shade: 0.6,
			icon: 16
		});
		$.ajax({
			type: 'POST',
			data: data.field,
			dataType: 'json',
			url: './system',
			success: function(data) {
				layer.msg('保存完成', {
					time: 1000,
					icon: 1
				})
			}
		});
		return false
	});
	$('.upload-img').hover(function(e) {
		var e = window.event || e;
		var imgsrc = $(this).val();
		if (imgsrc.trim() == "") {
			return
		}
		var left = e.clientX + document.body.scrollLeft + 20;
		var top = e.clientY + document.body.scrollTop + 20;
		$(".showpic").css({
			'left': left,
			'top': top,
			'width': "300px",
			'height': "200px",
			'display': ""
		});
		$(".showpic_img").attr("src", imgsrc)
	}, function(e) {
		$(".showpic").css("display", "none")
	})
});

 